<template>
	<view class="content">
		<view class="tabs">
			<view class="tab" @tap="changeSwiper(index)" :class="{active:tab_index == index}" v-for="(item,index) in tabs" :key="index">{{item}}</view>
		</view>
		<!-- <swiper :current="tab_index" @change="swiperChange"> -->
			<!-- 未分配 -->
			<view v-if="tab_index == 0">
				<view class="swiper-item">
					<view class="item" v-for="(item,index) in list" :key="index">
						<view class="title">{{item.project_name}}</view>
						<view class="type">项目类型：{{item.cate_name}}</view>
						<view class="type">服务项目：{{item.cate_names}}</view>
						<view class="type">亩数：{{item.number}}亩</view>
						<view class="name">申请人信息</view>
						<view class="info">{{item.contactor}}：{{item.contactor_phone}}</view>
						<view class="info">{{item.address}}</view>
						<view class="time">申请时间：{{item.createtime_text}}</view>
						<!-- <view class="time">服务人员：啊啊啊</view> -->
					</view>
				</view>
			</view>
			<!-- 进行中 -->
			<view v-if="tab_index == 1">
				<view class="swiper-item">
					<view class="item" v-for="(item,index) in list" :key="index">
						<view class="title">{{item.project_name}}</view>
						<view class="type">项目类型：{{item.cate_name}}</view>
						<view class="type">服务项目：{{item.cate_names}}</view>
						<view class="type">亩数：{{item.number}}亩</view>
						<view class="name">申请人信息</view>
						<view class="info">{{item.contactor}}：{{item.contactor_phone}}</view>
						<view class="info">{{item.address}}</view>
						<view class="time">申请时间：{{item.createtime_text}}</view>
						<view class="time">服务人员：{{item.serve_nickname}}</view>
					</view>
				</view>
			</view>
			<!-- 已完成 -->
			<view v-if="tab_index == 2">
				<view class="swiper-item">
					<view class="item" v-for="(item,index) in list" :key="index">
						<view class="title">{{item.project_name}}</view>
						<view class="type">项目类型：{{item.cate_name}}</view>
						<view class="type">服务项目：{{item.cate_names}}</view>
						<view class="type">亩数：{{item.number}}亩</view>
						<view class="name">申请人信息</view>
						<view class="info">{{item.contactor}}：{{item.contactor_phone}}</view>
						<view class="info">{{item.address}}</view>
						<view class="time">申请时间：{{item.createtime_text}}</view>
						<!-- <view class="time">服务人员：啊啊啊</view> -->
					</view>
				</view>
			</view>
			<view v-if="tab_index == 3">
				<view class="swiper-item">
					<view class="item" v-for="(item,index) in list" :key="index">
						<view class="title">{{item.project_name}}</view>
						<view class="type">项目类型：{{item.cate_name}}</view>
						<view class="type">服务项目：{{item.cate_names}}</view>
						<view class="type">亩数：{{item.number}}亩</view>
						<view class="name">申请人信息</view>
						<view class="info">{{item.contactor}}：{{item.contactor_phone}}</view>
						<view class="info">{{item.address}}</view>
						<view class="time">申请时间：{{item.createtime_text}}</view>
						<!-- <view class="time">服务人员：啊啊啊</view> -->
					</view>
				</view>
			</view>
			<view v-if="tab_index == 4">
				<view class="swiper-item">
					<view class="item" v-for="(item,index) in list" :key="index">
						<view class="title">{{item.project_name}}</view>
						<view class="type">项目类型：{{item.cate_name}}</view>
						<view class="type">服务项目：{{item.cate_names}}</view>
						<view class="type">亩数：{{item.number}}亩</view>
						<view class="name">申请人信息</view>
						<view class="info">{{item.contactor}}：{{item.contactor_phone}}</view>
						<view class="info">{{item.address}}</view>
						<view class="time">申请时间：{{item.createtime_text}}</view>
						<!-- <view class="time">服务人员：啊啊啊</view> -->
					</view>
				</view>
			</view>
		<!-- </swiper> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabs:['待指派','待接受','进行中','等待确认','已完成'],
				tab_index:0,
				list:[],
				page:1,
				last_page:1,
				statu:[5,1,2,3,4]
			}
		},
		onReachBottom() {
			if(this.last_page - this.page >= 0){
				this.loadData();
				this.page ++
			}
		},
		onLoad(options) {
			uni.setNavigationBarTitle({
			    title: options.title
			});
			this.tab_index = options.index;
			this.loadData()
		},
		methods: {
			swiperChange(e){
				this.page = 1;
				this.tab_index = e.detail.current;
				this.loadData();
			},
			changeSwiper(index){
				this.page = 1;
				this.tab_index = index;
				this.loadData();
			},
			loadData(){
				this.$http.post('/api/order/index',{
					status:this.statu[this.tab_index],
					page: this.page,
					limit:10,
				}).then(res => {
					console.log(this.page)
					this.last_page = res.data.data.last_page;
					if(this.page == 1){
						console.log(res.data.data.data)
						this.list = res.data.data.data;
						this.page=2
					}else{
						 this.list = this.list.concat(res.data.data.data)
						 //this.list = res.data.data.data;
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.content{
	min-height: 100vh;
	background-color: #F8F8F8;
	padding: 5rpx 30rpx 80rpx;
	box-sizing: border-box;
}
.tabs{
	display: flex;
	// justify-content: flex-start;
	justify-content: space-between;
	align-items: center;
	padding: 30rpx 0rpx;
	// box-sizing: border-box;
	.tab{
		font-size:15px;
		font-family:PingFang SC;
		font-weight:500;
		color:rgba(51,51,51,1);
	    // margin-right: 42rpx;
		&.active{
			font-size:20px;
			font-family:PingFang SC;
			font-weight:bold;
			color:rgba(63,195,119,1);
		}
	}
}
// swiper{
// 	height: calc(100vh - 116rpx);
// 	overflow: scroll;
// }
// .swiper-item{
// 	height: calc(100vh - 116rpx);
// 	overflow: scroll;
// }
.item{
	padding: 30rpx;
	box-sizing: border-box;
	width: 690rpx;
	background:rgba(255,255,255,1);
	border-radius:20px;
	margin-bottom: 30rpx;
	// height: 540rpx;
	.title{
	
		font-size:17px;
		font-family:PingFang SC;
		font-weight:bold;
		color:rgba(51,51,51,1);
	}
	.type{
		font-size:15px;
		font-family:PingFang SC;
		font-weight:500;
		color:rgba(51,51,51,1);
		margin-top: 29rpx;
	}
	.name{
		font-size:17px;
		font-family:PingFang SC;
		font-weight:bold;
		color:rgba(51,51,51,1);
		margin-top: 50rpx;
	}
	.info{
		font-size:16px;
		font-family:PingFang SC;
		font-weight:500;
		color:rgba(51,51,51,1);
		margin-top: 28rpx;
	}
	.time{
		font-size:17px;
		font-family:PingFang SC;
		font-weight:bold;
		color:rgba(63,195,119,1);
		margin-top: 43rpx;
	}
}
</style>
